<?php
require('../../cofd/common.php');
$json_j = file_get_contents("php://input");
$json_jx = json_decode($json_j, true);
$penname 	= $json_jx['penname'];
$sentence = $json_jx['sentence'];
$userid 	= $json_jx['userid'];
$sql = "select * from novelwrite where (writer='$userid' and (zg = 0 or zg = 1 ) ) or penname='$penname'";
$result = $conn->query($sql);
if($result->num_rows > 0){
    echo json_encode(array("code"=>400, "msg"=>"该笔名已存在或已有资格（审核中）"));
    $conn->close();
    return;
}
$sql = "insert into novelwrite (writer,penname,sentce,zg) values ('$userid','$penname','$sentence',0)";
if($conn->query($sql)){
    echo json_encode(array("code"=>200, "msg"=>"已提交，请等待审核"));
}else{
    echo json_encode(array("code"=>400, "msg"=>"异常error"));
}
$conn->close();
?>